package com.mjk.common.core.jdbc.service.plus.mapper;


import com.mjk.common.base.model.BaseEntity;
import com.mjk.common.base.model.BaseExample;
import com.mjk.common.core.jdbc.service.plus.provider.impl.example.ExampleSQLProvider;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface ExampleMapper<T extends BaseEntity, K extends BaseExample> {
    @SelectProvider(type= ExampleSQLProvider.class, method="selectByExample")
    @ResultType(Map.class)
    List<Map<String,Object>> selectByExample(@Param("example") BaseExample paramBaseExample);

    @SelectProvider(type=ExampleSQLProvider.class, method="selectByPrimaryKey")
    List<Map<String,Object>> selectByPrimaryKey(@Param("dto") BaseEntity paramBaseEntity);

    @SelectProvider(type=ExampleSQLProvider.class, method="excuteSql")
    List<Map<String,Object>> excuteSelectSql(String paramString);

    @SelectProvider(type = ExampleSQLProvider.class, method = "countByExample")
    Integer countByExample(@Param("example") K paramK);

    @DeleteProvider(type = ExampleSQLProvider.class, method = "deleteByExample")
    Integer deleteByExample(@Param("example") K paramK);

    @InsertProvider(type = ExampleSQLProvider.class, method = "insert")
   // @Options(useGeneratedKeys=true,keyProperty = "id",keyColumn = "id")
    Integer insertSelective(@Param("item") T paramT);
     
    @InsertProvider(type = ExampleSQLProvider.class, method = "insert")
    @Options(useGeneratedKeys=true,keyProperty = "id",keyColumn = "id")
    Integer insertSelectivewithId(@Param("item") T paramT);
    
    @DeleteProvider(type = ExampleSQLProvider.class, method = "deleteByPrimaryKey")
    Integer deleteByPrimaryKey(T paramT);

    @UpdateProvider(type = ExampleSQLProvider.class, method = "updateByExampleSelective")
    Integer updateByExampleSelective(@Param("dto") T paramT, @Param("example") K paramK);

    @UpdateProvider(type = ExampleSQLProvider.class, method = "updateByPrimaryKeySelective")
    Integer updateByPrimaryKeySelective(@Param("dto") T paramT);

    @SelectProvider(type = ExampleSQLProvider.class, method = "excuteSql")
    List<Map<String,Object>> excuteSql(Map<String, Object> paramString);

    @InsertProvider(type = ExampleSQLProvider.class, method = "insertBaseList")
    Integer insertList(@Param("list") List<T> paramList);

    @DeleteProvider(type = ExampleSQLProvider.class, method = "deleteBaseList")
    Integer deleteList(@Param("list") List<T> paramList);

    @UpdateProvider(type = ExampleSQLProvider.class, method = "updateBaseList")
    Integer updateList(@Param("list") List<T> paramList);
}